package com.faiz.picturebed.common;

import java.util.Optional;

public class CastUtil {

    @SuppressWarnings("unchecked")
    public static <T> Optional<T> safeCast(Object object, Class<T> clazz) {
        if (clazz.isAssignableFrom(object.getClass())) {
            return Optional.of((T) object);
        } else {
            return Optional.empty();
        }
    }
}
